package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.BannerDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.Banner;
import org.sixtynine.stock.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Thilan
 *
 */

@Service
public class BannerServiceImpl implements BannerService {

	@Autowired
	private BannerDao bannerDao;
	
	@Override
	public Banner findById(int id) {
		return bannerDao.findById(id);
	}

	@Override
	public void saveBanner(Banner banner) {
		bannerDao.saveBanner(banner);
	}

	@Override
	public void deleteBanner(int id) {
		Banner banner = bannerDao.findById(id);
		if (banner != null) {
			bannerDao.delete(banner);
		}
	}

	@Override
	public List<Banner> findBanner(String name) {
		return bannerDao.findBanner(name);
	}

	@Override
	public List<Banner> searchBanner(Date fromDate, Date toDate) {
		return bannerDao.searchBanner(fromDate,
				toDate);
	}

	@Override
	public Page<Banner> searchBanner(Date fromDate, Date toDate,
			GridPramDTO gridPramDTO) {
		return bannerDao.searchBanner(fromDate,
				toDate, gridPramDTO);
	}

}
